
  <div class="x_panel">
    <div class="x_content" style="display: block;">
      <!--表格主体内容-->
      <div class="nav navbar-left panel_toolbox">
        <select class="form-control-area" style="width:150px" id="plan_id" name="form[plan_id]">
          {foreach $plan AS $key => $value}
          <option value="{$value.plan_id}" {if $value.plan_id==1}selected="selected"{/if}>佣金方案{$key+1}</option>
          {/foreach}
        </select>
        <a class="fa fa-plus" href="/commission/add.html"> 添加</a>
      </div>
      <div class="cont">
        <table class="table table-bordered table-striped">
          <thead>
          <tr>
            <th width="100px">序号</th>
            <th>角色</th>
            <th>类型</th>
            <th>佣金比例</th>
            <th>操作</th>
          </tr>
          </thead>
          <tbody id="result">
          {foreach $commission as $commissionitem}
          <tr>
            <td>{$commissionitem.config_id}</td>
            <td>{if $commissionitem.role==1}店主{else}店长{/if}</td>
            <td>{if $commissionitem.type==0}入场券使用{elseif $commissionitem.type==1}会员卡使用{elseif $commissionitem.type==2}商品出售{elseif $commissionitem.type==3}商品回收{elseif $commissionitem.type==4}摇摇车{/if}</td>
            <td>{$commissionitem.config_value}%</td>
            <td>
              <div class="x_content">
                <a class="btn btn-primary btn-xs" href="{eval U(['commission/edit','config_id'=>$commissionitem.config_id])}"> 编辑</a>
              </div>
            </td>
          </tr>
          {/foreach}
          </tbody>
        </table>
      </div>
    </div>
  </div>
  <script>
      $("#plan_id").change(function(){
          var plan_id = $(this).val();
          var url = "{['commission/config']|U}";
          $.post(url, 'plan_id='+plan_id, function (data) {
              $('#result').html('');
              $.each(data, function(i,val){
                  id = val.config_id;
                  url = "/commission/edit.html?config_id="+id;
                  html = "<tr>";
                  html += "<td>"+val.config_id+"</td>";
                  if(val.role==1){
                      html += "<td>店主</td>";
                  }else{
                      html += "<td>店长</td>";
                  }
                  if(val.type==0){
                      html += "<td>入场券使用</td>";
                  }else if(val.type==1){
                      html += "<td>会员卡使用</td>";
                  }else if(val.type==2){
                      html += "<td>商品出售</td>";
                  }else if(val.type==3){
                      html += "<td>商品回收</td>";
                  }else if(val.type==4){
                      html += "<td>摇摇车</td>";
                  }
                  html += "<td>"+val.config_value+"%</td>";
                  html += "<td>"+'<div class="x_content"><a class="btn btn-primary btn-xs" href="'+url+'"> 编辑</a></div>'+"</td>";
                  html += "</tr>";
                  $('#result').append(html)
              });
          },'json');
      });
  </script>

